﻿package export.magicWeapon
{
	import base.BaseBitmapDataClip;
	import base.BaseBitmapDataPool;
	import base.BaseHero;
	import base.BaseMagicWeapon;
	
	import com.game.data.vo.EquipmentVO;
	import com.game.manager.GameSceneManager;
	import com.greensock.TweenMax;
	
	import export.bullet.EnemyMoveBullet;
	import export.bullet.SpecialEffectBullet;
	
	import flash.geom.Point;
	
	public class MagicLing extends BaseMagicWeapon
	{
		
		public function MagicLing(param1:BaseHero)
		{
			super(param1);
		}
		
		private var totalNum:int = 120;
		
		override protected function initBBDC():void
		{
			var _loc1_:* = null;
			var _loc2_:Array = BaseBitmapDataPool.getBitmapDataArrayByName("LingBmd");
			if (_loc2_)
			{
				_loc1_ = {
					"name"  : "body",
					"source": _loc2_
				};
				bbdc = new BaseBitmapDataClip([_loc1_], 150, 150, new Point(0, 0));
				bbdc.setOffsetXY(0, 0);
				bbdc.setFrameStopCount([[5, 5, 5, 5, 5, 5], [9999]]);
				bbdc.setFrameCount([6, 1]);
				bbdc.setAddScriptWhenFrameOver(scriptFrameOverFunc);
				this.addChild(bbdc);
				return;
			}
			throw new Error("Ling--BitmapData Error!");
		}
		
		override public function showSkill():void
		{
			var _loc1_:int;
			var equip:EquipmentVO = null;
			var equiplevel:uint = 0;
			var cd:int = 30;
			var bb:SpecialEffectBullet = new SpecialEffectBullet("LingPaiEffect");
			var posision:Point = GameSceneManager.getIns().mainStage.globalToLocal(new Point(940 / 2, 590 / 2));
			bb.x = posision.x;
			bb.y = posision.y;
			bb.setDisable();
			bb.setOwner(this.sourceRole);
			bb.setAction("idle");
			this.sourceRole.magicBulletArray.push(bb);
			gc.gameScene.addChild(bb);
			_loc1_ = 0;
			while (_loc1_ < this.totalNum)
			{
				this.createSnow();
				_loc1_++;
			}
			if (this.sourceRole.getPlayer())
			{
				equip = this.sourceRole.getPlayer().getCurEquipByType("zbfb");
				if (equip)
				{
					if (equip.getFiveElementString().indexOf("木") != -1)
					{
						cd = 27;
					}
					equiplevel = equip.getLevel();
				}
			}
			TweenMax.delayedCall(cd, function (param1:MagicLing):*
			{
				param1.setAction("idle");
			}, [this]);
		}
		
		private function createSnow():void
		{
			var _loc1_:Number = 0;
			var _loc2_:EnemyMoveBullet = new EnemyMoveBullet("ef_snow");
			_loc2_.x = -gc.gameScene.x - 500 + Math.random() * (940 + 300);
			_loc2_.y = -gc.gameScene.y - 480 + Math.random() * 100;
			_loc1_ = 50 + 10 * Math.random();
			var _loc3_:Number = _loc1_ / 180 * 3.141592653589793;
			var _loc4_:Number = Math.random() * 10 / 2 + 10;
			_loc2_.setSpeed(Math.cos(_loc3_) * _loc4_, Math.sin(_loc3_) * _loc4_);
			_loc2_.rotation = _loc1_;
			_loc2_.alpha = Math.random() + 0.2;
			_loc2_.setDirect(0);
			_loc2_.setIsDestroyWhenLastFrame(false);
			_loc2_.setDistance(1500);
			_loc2_.setOwner(this.sourceRole);
			_loc2_.setAction("fabao-snow");
			this.sourceRole.magicBulletArray.push(_loc2_);
			gc.gameScene.addChild(_loc2_);
		}
	}
}
